package com.webchat.dao;

import com.webchat.Utils.HibernateUtil;
import com.webchat.model.UsersMessageEntity;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 * Created by YongX on 2016/8/21.
 */
public class UsersMessageDao {
    private Session session;

    public UsersMessageDao(){
        this.session = HibernateUtil.getSessionFactory().openSession();
    }

    public void save(UsersMessageEntity usersMessageEntity){
        session.beginTransaction();
        session.save(usersMessageEntity);
        session.getTransaction().commit();
    }

    public void closeSession(){
        session.close();
    }
}
